{extend name="public/base" /}
{block name="head"}
{/block}
{block name="body"}
<div id="fuyun-app" class="fuyun-app">
  <div class="search-box">
    <div class="fuyun-title">
      <h5>筛选条件</h5>
    </div>
    <div class="search-content">
      <form class="layui-form" action="{:Url('index')}" method="get">
        <div class="fuyun-form-item layui-inline">
          <label>文章分类</label>
          <select name="category_id">
            <option value="-1">全部</option>
            {volist name="categoryList" id="cate"}
              <option value="{$cate.id}" <?php if(Request::instance()->param('category_id',-1) == $cate['id']){echo 'selected';} ?>>{$cate.category_name}</option>
            {/volist}
          </select>
        </div>

        <div class="fuyun-form-item layui-inline">
          <label>文章标题</label>
          <input class="layui-input" type="text" name="title" placeholder="输入文章标题" value="{$Request.param.title}">
        </div>

        <div class="fuyun-form-item layui-inline" style="padding-top:18px;">
          <button class="layui-btn layui-btn-normal">搜索</button>
        </div>
      </form>
    </div>
  </div>


  <div class="content-box">
    <div class="fuyun-title">
      <h5>文章列表</h5>
      <a href="{:Url('create')}" class="layui-btn fuyun-add-btn layui-btn-small layui-btn-normal add"><i class="fa fa-plus-square margin-right-5"></i>添加文章</a>
    </div>
    <div class="main-box">
      <div class="layui-form">
        <table class="layui-table layui-form">
          <thead>
            <tr>
              <th width="5%">id</th>
              <th width="10%">标题</th>
              <th width="10%">分类</th>
              <th width="10%">展示时间</th>
              <th width="5%">封面</th>
              <th width="10%">状态</th>
              <th width="8%">操作</th>
            </tr> 
          </thead>
          <tbody>
            {volist name="list['data']" id="vo"}
              <tr data-id="{$vo.id}">
                <td>{$vo.id}</td>
                <td>{$vo.title}</td>
                <td>{$vo.category_name}</td>
                <td>{$vo.show_time}</td>
                <td>
                  <a show-img="{$vo.cover}" href="javascript:;" onclick="show_img(this)" >查看</a>
                </td>
                <td>
                  {if condition="$vo['status'] eq 0"}
                    未发布
                  {elseif condition="$vo['status'] eq 1"}
                    发布
                  {/if}
                </td>
                <td>
                  <div class="layui-btn-group">
                    <a class="layui-btn layui-btn-normal layui-btn-small" href="{:Url('update',['id'=>$vo['id']])}">编辑</a>
                    <button class="layui-btn fuyun-btn-del layui-btn-small btn-del-id" data-url="{:Url('deleteAll')}" data-confirm="确定删除该配置项吗？" data-successtip="删除成功！" data-id="<?=$vo['id']?>" ><i class="fa fa-close margin-right-5"></i>删除</button>
                  </div>
                </td>
              </tr>
            {/volist}
          </tbody>
        </table>
      </div>
      <div class="page-box">
        <fuyun-page v-if="<?=ceil($list['totalRow']/$list['pageSize'])?> > 1"
          :pagesize="<?=$list['pageSize']?>" 
          :total = "<?=$list['totalRow']?>"
          :current-page = {$list['curPage']}
        ></fuyun-page>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
  layui.use([ 'layer','form'], function(){
    var layer = layui.layer;
    var form = layui.form();
    //全选
    form.on('checkbox(allChoose)', function(data){
      var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
      child.each(function(index, item){
          item.checked = data.elem.checked;
      });
      form.render('checkbox');
    });
  });

  fuyun.components(['page'],{
    el:"#fuyun-app",
    data:{
      labelPosition: 'top',
    },
  });


  function show_img(obj){
    var url = $(obj).attr("show-img");
    layer.photos({
      photos: {
        "title": "", //相册标题
        "id": 123, //相册id
        "start": 0, //初始显示的图片序号，默认0
        "data": [   //相册包含的图片，数组格式
          {
            "alt": "图片名",
            "pid": 666, //图片id
            "src": url,
            "thumb": url
          }
        ]
      }
      ,anim: 5
    });    
  }

</script>
{/block}
